﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VIP_Shop.Business_Logic
{
    class ThongTinKH
    {
        DataTable datatable = new DataTable();
        VIP_Shop.Access_Data.AccessData data;
        BindingSource binding;
        Form frm;

        public ThongTinKH(VIP_Shop.GUI.ThongTinKH frm)
        {
            data = new Access_Data.AccessData();
            this.frm = frm;
        }
        public void Load()
        {

            datatable = data.get_Datatable("select * from khachhang");
            binding = new BindingSource();
            binding.DataSource = datatable;
            DataGridView grid = (DataGridView)frm.Controls["dataGridView1"];
            grid.DataSource = binding;
            grid.Columns["makh"].ToolTipText = "Ma hang khong the chinh sua";
            grid.Columns["hoten"].SortMode = DataGridViewColumnSortMode.Automatic;


        }
        public void finded()
        {
            try
            {
                string hoten = ((TextBox)frm.Controls["TextBox1"]).Text;
                DataTable datatable1 = data.get_Datatable1("select * from khachhang where hoten " + "like'" + hoten + "%'");
                BindingSource binding1 = new BindingSource();
                binding1.DataSource = datatable1;
                DataGridView grid1 = (DataGridView)frm.Controls["dataGridView1"];
                grid1.DataSource = binding1;


            }
            catch (SqlException err)
            {
                MessageBox.Show(err.Message);
            }
        }

    }
}
